package com.leyou.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @author xhh
 * @date 2022/4/5
 */
@Component
@Configuration
public class MyBetaObjectHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        Date date=new Date();
        this.setFieldValByName("insertTime",date,metaObject);
        this.setFieldValByName("modifiedTime",date,metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        Date date=new Date();
        this.setFieldValByName("modifiedTime",date,metaObject);
    }
}
